<?php
namespace Home\Controller;
use Think\Controller;
class AboutmeController extends Controller {
	public function index(){
		//$user_id = session('uid.id');
		/*$user_id = session('uid.id');
		$data = M('user')->where('id='.$user_id)->find();
		$this->assign('data',$data);*/
		$this->display();
	}
	public function upinfo(){
        if (IS_POST) {
            $user = I('post.');
            if ($user['password']=='') {
                $this->error('密码为空，请输入!');
            }
            if ($user['password1']=='') {
                $this->error('新密码为空，请输入');
            }
            if ($user['password2']=='') {
                $this->error('新密码为空，请输入');
            }
            if ($user['password2']!=$user['password1']) {
                $this->error('两次密码不同，请重新输入');
            }
            if ($user['password1']!='') {
                $userinfo['password']=md5($user['password']);
            }
            $pwd=M('user')->where(array('id'=>session('uid.id')))->getField('password');
            if ($pwd!=$userinfo['password']) {
                $this->error('旧密码有错！');
            }
            $data=M('user')->where(array('id'=>session('uid.id')))->save(array('password'=>md5($user['password1'])));
            if ($data === fales) {
                $this->error('网络超时，请重试！');
            }else{
                $this->success('修改成功');
            }
        }
        $this->display();
    }
    public function myinfo(){
        $user_id = session('uid.id');
        if ($user_id) {
            $user = M('user')->where('id='.$user_id)->find();
            if (!$user) {
                $result['status']=0;
                $result['message']='参数错误';
                $this->ajaxReturn($result);
            }
            $result['status']=1;
            $result['message']='请求成功';
            $result['user']=$user;
            $this->ajaxReturn($result);
        }else{
            $result['status']=0;
                $result['message']='参数错误';
                $this->ajaxReturn($result);
        }
    }
    public function purse(){
        $this->display();
    }
    public function share(){
        $this->display();
    }
}